home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / September 96 / Re Creating an OpenDoc file? < prev    next >
Encoding:
Internet Message Format  |  1996-09-19  |  2.4 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Creating an OpenDoc file?
  2. Sent:        9/13/96 4:24 PM
  3. Received:    9/13/96 4:24 PM
  4. From:        mlanett@meer.net (Mark Lanett)
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List
  7.  
  8.  
  9. >I have caught the "Save A Copy" command and done my own Save As dialog and
  10. >can now output TEXT files. Now I would like to output OpenDoc documents
  11. >like CyberDog 1.1. Is there a way to redirect command and bypass the
  12. >default Save A Copy dialog? If not, how can I setup the file so that it has
  13. >all the right OpenDoc stuff in it, along with my data?
  14.  
  15. What do you mean by "like Cyberdog 1.1"? Are you implementing a CD display
  16. part (navor-aware), or you just want a Save As command in your non-CD part?
  17.  
  18. If you are *not* writing a CD part then this is easy. You may wish to look
  19. at the OD source code for RealShell::SaveACopy (RlShell.cpp), but it boils
  20. down to this:
  21.  
  22.  
  23. TempPlatformFile file = new PlatformFile();
  24. file->Specify(&reply.sfFile);
  25. ODSaveACopyOfDraft (ev, session, draft, file);
  26.  
  27. If your part is CD navigator-aware, things are harder. This is because the
  28. way CD save as works, you are trying to save your (embedded) part out as
  29. the new root part of a new document, but in the current draft the root part
  30. is the CD navigator. Therefore cloning the draft doesn't work. ODF R2 has
  31. some Save As code but I punted on this at the time. This is my work in
  32. progress (it'll be posted to the web page once it's done).
  33.  
  34. FW_CAcquiredODContainer fc = ::CreateFileContainer (ev, session, &reply.sfFile);
  35. FW_CAcquiredODDocument doc = fc->AcquireDocument (ev, kODDefaultDocument);
  36. FW_CAcquiredODDraft d = doc->AcquireBaseDraft (ev, kODDPExclusiveWrite);
  37. FW_CAcquiredODStorageUnit c = d->CreateStorageUnit (ev);
  38.  
  39. FW_CAcquiredODStorageUnit p = d->AcquireDraftProperties (ev);
  40. ODSetStrongSURefProp (ev, p, kODPropRootPartSU, kODStrongStorageUnitRef,
  41. c->GetID(ev));
  42.  
  43. c->AddProperty (ev, kODPropContents);
  44. // now you have to externalize your contents to this storageunit
  45.  
  46. This snippet will result in an incomplete document, without a frame or
  47. window storageunit. This is ok for leaf parts but it won't if you are
  48. externalizing an embedding part.
  49.  
  50. Both of these snippets leave out the resources (CODE, SIZE, etc). This
  51. should be ok unless you really need more process memory when the new
  52. document is launched.
  53.  
  54.  
  55. --
  56. Mark Lanett <mlanett@meer.net>
  57. Have a bajillion brilliant Jobsian lithium licks